package SwingView.Quiz;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import JDBC.InstructorQuizActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsQuiz;
import SwingModel.CmsUser;
import SwingView.CmsMainView;

public class ALQuizPost implements ActionListener{

	@Override
	public void actionPerformed(ActionEvent e) {
		CmsUser user = CmsPresenter.user;
		CmsMainView mainView = CmsPresenter.mainView;
		CmsCPQuizComposer qComposer = mainView.getContentPanel().getQuizComposerPage();
		
		if(qComposer.validateAllInput() == true){
			System.out.println(qComposer.getComposedQuiz().toString());
			CmsQuiz quiz = mainView.getContentPanel().getQuizComposerPage().getComposedQuiz();
			InstructorQuizActivities.postQuiz(CmsPresenter.user.getSelectedCourse().getCourseID(), quiz);
			
			qComposer.clearAllInput();
			mainView.displayQuizInstructorPage(InstructorQuizActivities.getListOfQuiz(user.getSelectedCourse().getCourseID()));
		}
		
	}

	
}
